

package com.thxrinfo.stop.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.common.log.annotation.SysLog;
import com.thxrinfo.stop.api.entity.ParkingPort;
import com.thxrinfo.stop.api.vo.ParkingPortVO;
import com.thxrinfo.stop.service.ParkingPortService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;


/**
 * 进出口管理
 *
 * @author silencezheng
 * @date 2022-12-28 15:03:37
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/parkingport" )
@Tag(name = "进出口管理管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ParkingPortController {

    private final  ParkingPortService parkingPortService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param parkingPort 进出口管理
     * @return
     */
    @Operation(summary = "分页查询", description = "分页查询")
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('stop_parkingport_get')" )
    public R<IPage<ParkingPortVO>> getParkingPortPage(Page page, ParkingPort parkingPort) {
        return R.ok(parkingPortService.selectPage(page,parkingPort));
    }


    /**
     * 通过id查询进出口管理
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('stop_parkingport_get')" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(parkingPortService.getParkingPortInfo(id));
    }

    /**
     * 新增进出口管理
     * @param parkingPort 进出口管理
     * @return R
     */
    @Operation(summary = "新增进出口管理", description = "新增进出口管理")
    @SysLog("新增进出口管理" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('stop_parkingport_add')" )
    public R save(@RequestBody ParkingPort parkingPort) {
        return R.ok(parkingPortService.save(parkingPort));
    }

    /**
     * 修改进出口管理
     * @param parkingPort 进出口管理
     * @return R
     */
    @Operation(summary = "修改进出口管理", description = "修改进出口管理")
    @SysLog("修改进出口管理" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('stop_parkingport_edit')" )
    public R updateById(@RequestBody ParkingPort parkingPort) {
        return R.ok(parkingPortService.updateById(parkingPort));
    }

    /**
     * 通过id删除进出口管理
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id删除进出口管理", description = "通过id删除进出口管理")
    @SysLog("通过id删除进出口管理" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('stop_parkingport_del')" )
    public R removeById(@PathVariable Long id) {
        return R.ok(parkingPortService.removeById(id));
    }

}
